<?php
namespace Kite\Exception;

use Kite\Exception\IException;

class Exception extends \Exception implements IException
{
	protected $code;
	protected $message;
	protected $file;
	protected $line;
	
	public function __construct(string $msg = null, int $code = 0)
	{
		if (!$msg) {
			$msg = "Unknown".get_class($this);
		}
		parent::__construct($msg, $code);
	}
	
	public function __toString()
	{
		return get_class($this).': ['.$this->getCode().'] '.$this->getMessage().
			'in file "'.$this->getFile().'" at line '.$this->getLine();
	}
	
	public function getCode()
	{
		return $this->code;
	}
	
	public function getMessage()
	{
		return $this->message;
	}
	
	public function getFile()
	{
		return $this->file;
	}
	
	public function getLine()
	{
		return $this->line;
	}
}